package com.foreknow.tijian.controller;


import com.foreknow.tijian.po.Food;
import com.foreknow.tijian.service.FoodService;
import com.foreknow.tijian.service.Impl.FoodServiceImpl;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.List;

//连接前后端
public class FoodController {

    /**
     * HttpServletRequest
     * 提供一些方法用于获取前台传递到后台的请求参数
     * 客户端向服务端发送请求的url地址
     * http://localhost:8080/elm/FoodController/listFoodByBusinessId?businessId=10001
     * @return
     */
    public Object listFoodByBusinessId(HttpServletRequest request) throws SQLException {
        //获取前台的请求参数
        String businessId= request.getParameter("businessId");
        //调用Service中的方法
        FoodService foodService=new FoodServiceImpl();
        List<Food> list=foodService.listFoodByBusinessId(Integer.parseInt(businessId));
        return list;
    }
}
